package org.hiberlyzer.impl;

import org.hiberlyzer.DataColumn;
import org.hibernate.EntityMode;
import org.hibernate.metadata.ClassMetadata;

public class EntityDataColumn implements DataColumn
{
	private String name;
	private ClassMetadata metadata;
	private EntityMode entityMode;
	
	EntityDataColumn(String name, ClassMetadata metadata, EntityMode entityMode)
	{
		this.name = name;
		this.metadata = metadata;
		this.entityMode = entityMode;
	}

	public String getName()
	{
		return name;
	}

	public boolean hasMetadata()
	{
		return true;
	}

	public String formatValue(Object entity)
	{
		if(entity == null)
		{
			return "NULL";
		}
		return metadata.getEntityName() + ":" + metadata.getIdentifier(entity, entityMode);
	}
}
